package com.webapi.core.model.dto;

import java.util.ArrayList;
import java.util.List;

import com.webapi.common.utils.DateUtils;
import com.webapi.core.model.common.TicketStatus;
import com.webapi.core.model.persist.Ticket;

public class TicketDto extends BaseDto {

    private String no;
    private TicketStatus status;
    private Double price;
    private String name;

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public TicketStatus getStatus() {
        return status;
    }

    public void setStatus(TicketStatus status) {
        this.status = status;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static List<TicketDto> valueOf(List<Ticket> tickets) {
        List<TicketDto> dtos = new ArrayList<TicketDto>();
        for (Ticket ticket : tickets) {
            TicketDto dto = new TicketDto();
            dto.setId(ticket.getId());
            dto.setName(ticket.getName());
            dto.setNo(ticket.getNo());
            dto.setPrice(ticket.getPrice());
            dto.setStatus(ticket.getStatus());
            dto.setCreateTime(DateUtils.date2stringLong(ticket.getCreateTime()));
            dtos.add(dto);
        }
        return dtos;
    }

    @Override
    public String toString() {
        return "TicketDto [no=" + no + ", status=" + status + ", price="
                + price + ", name=" + name + ", getId()=" + getId()
                + ", getCreateTime()=" + getCreateTime() + "]";
    }
}
